Skip to content

refactor(networking): remove discv5 package and test surface#734

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/remove-discv5-package
May 20, 2026
Merged

refactor(networking): remove discv5 package and test surface#734
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/remove-discv5-package

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

  • Deletes the ~3,300 LOC subspecs/networking/discovery/ package along with its unit tests, consensus spec fillers, and the associated test-fixture infrastructure (~14k lines removed net).
  • Keeps subspecs/networking/enr/ — the ENR record format is shared by every lean client.
  • Updates two stale docstrings in peer.py / types.py that previously referred to data being "populated from discovery".

Why

Cross-client survey of production lean Ethereum clients:

Client Uses discv5? What it uses
Ream (lean target) No libp2p + identify + req_resp + gossipsub; static ENR/multiaddr bootnodes from config
ethlambda No libp2p + QUIC; parse_enrs() from a bootnodes: Vec<Bootnode> config for static dialing
zeam No libp2p (eth-p2p-z) + QUIC; ENR-from-yaml for static peers
Lighthouse (beacon, reference) Yes Full discv5 — but lean clients are explicitly not replicating this

Notably, Ream's repo contains a discv5 Rust crate but its lean ReamBehaviour composes only identify / req_resp / gossipsub / slow_peer_banlist / connection_limits — no discovery behaviour. The discv5 crate is used only by Ream's beacon-chain target.

The discv5 wire protocol implementation in leanSpec appears to have been carried over from beacon-chain assumptions and has zero production consumers across the lean ecosystem.

Scope of deletion

  • src/lean_spec/subspecs/networking/discovery/ — 11 production files
  • tests/lean_spec/subspecs/networking/discovery/ — 15 unit test files
  • tests/consensus/lstar/networking/test_discv5_*.py and test_discovery_*.py — 5 consensus spec fillers (no lean client consumes the JSON vectors they emitted)
  • packages/testing/src/consensus_testing/test_fixtures/discovery_crypto.py (fixture class)
  • discv5 sections of packages/testing/src/consensus_testing/test_fixtures/networking_codec.py (dispatch cases, decoder map entries, _make_discv5_message, _make_discv5_packet, _make_xor_distance, _make_log2_distance, _build_discv5_message)
  • make_challenge_data helper in tests/lean_spec/helpers/builders.py (used only by deleted unit tests)
  • Public exports of DiscoveryCryptoTest / DiscoveryCryptoTestFiller

Test plan

  • ruff check — passes
  • ruff format --check — passes
  • ty check — passes
  • codespell — passes
  • mdformat --check docs/ — passes
  • uv lock --check — passes
  • Full pytest suite on CI

🤖 Generated with Claude Code

No lean Ethereum client (Ream, ethlambda, zeam) implements discv5;
all converge on libp2p + QUIC with ENR records loaded from static
bootnode configuration. The discv5 wire protocol implementation was
carried over from beacon-chain assumptions and has zero production
consumers.

Removes:
- src/lean_spec/subspecs/networking/discovery/ (11 files)
- tests/lean_spec/subspecs/networking/discovery/ (15 files)
- tests/consensus/lstar/networking/test_discv5_*.py and test_discovery_*.py (5 fillers)
- packages/testing/.../test_fixtures/discovery_crypto.py
- discv5 sections of test_fixtures/networking_codec.py
- make_challenge_data helper in tests/lean_spec/helpers/builders.py

Keeps subspecs/networking/enr/ (ENR record format is used by all lean
clients as a static address record).

Updates peer.py and types.py docstrings to drop stale references to
"populated from discovery" / "for Discovery v5".

Net change: 14k lines removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit d9d2e67 into leanEthereum:main May 20, 2026
13 checks passed
tcoratger added a commit that referenced this pull request May 21, 2026
…, fixtures (#736)

* refactor(networking): drop dead code across gossipsub, ENR, transport, fixtures

Nine targeted cleanups identified by an audit of the networking
subspec. Each item is either entirely unused in production or fully
superseded by a different code path.

Deletions:
- TTFB_TIMEOUT — unused constant.
- GOSSIPSUB_PROTOCOL_ID_V11 — never advertised; default is v1.2.
  Stale v1.1 docstring references updated to v1.2.
- negotiate_client (eager protocol negotiation) — production uses
  negotiate_lazy_client; this variant was test-only.
- PrunePeerInfo + ControlPrune.peers (PRUNE peer-exchange) — never
  produced or consumed.
- ENR.ip6 / udp6_port / quic6_port plus IP6 / UDP6 / QUIC6 keys,
  the IPv6 branches in parse_multiaddr and ENR.multiaddr — no
  production caller; IPv6 not on the roadmap.
- SyncCommitteeSubnets + SYNCNETS + ENR.sync_committee_subnets —
  lean Ethereum has no sync committees.
- SnappyDecompressor type + GossipsubMessage.snappy_decompress field
  + the lazy snappy branch in compute_id — production always passes
  domain= explicitly.
- NOISE_IDENTITY_PREFIX + create_identity_proof + verify_identity_proof
  (entire signature.py module) — Noise handshake was replaced by
  QUIC + libp2p-tls; zero production callers.

Refactor:
- Three call sites computing self._gossipsub_behavior._instance_id %
  0xFFFF now read the existing _short_id field. Fixes an off-by-one
  inconsistency: the source used % 0x10000 (0..65535) while the
  duplicates used % 0xFFFF (0..65534).

Interop fixture sweep:
- Mirrors the discv5 PR #734 precedent: the corresponding sections
  in packages/testing/.../networking_codec.py (_build_prune_peer,
  IPv6 emission, sync_committee_subnets emission) are removed too,
  since the protocol features they exercise no longer exist.

Net: 28 files, 57 insertions, 980 deletions, 2 files deleted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* style: fix ruff format on test files

Trailing whitespace left over from the targeted deletions in
the previous commit. No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant